<script setup>
import { onMounted, ref } from 'vue'
import CompoEchartsPie from '@renderer/components/CompoEchartsPie.vue'
import ConfigSettings from '@renderer/views/ConfigSettings.vue'
const barData = ref({})
const showSettings = ref(false)
onMounted(() => {
  if (document.documentElement.clientWidth / document.documentElement.clientHeight >= 1.7) {
    document.documentElement.style.fontSize =
      (document.documentElement.clientWidth * 9 + document.documentElement.clientHeight * 16) /
        2500 +
      'px'
  } else {
    document.documentElement.style.fontSize =
      (document.documentElement.clientWidth * 7 + document.documentElement.clientHeight * 12) /
        1800 +
      'px'
  }
  window.main2render.receive('data-change', (data) => {
    barData.value = data.data
  })
})
function openSettings(){
  showSettings.value = true
}
function closeSettings(){
  showSettings.value = false
}
</script>

<template>
  <div id="main_container" class="full_screen">
    <CompoEchartsPie
      id="gdp3inds"
      title-name="GDP三次产业构成"
      :bar-data="barData"
    ></CompoEchartsPie>
    <el-button id="button01" type="primary" @click="openSettings">设置</el-button>
  </div>
  <div v-if="showSettings" id="config_container" class="full_screen">
    <ConfigSettings></ConfigSettings>
    <el-button id="buttonclose" type="primary" @click="closeSettings">关闭</el-button>
  </div>
</template>

<style lang="scss" scoped>
.full_screen {
  width: 100vw;
  height: 100vh;
  position: absolute;
  left: 0;
  top: 0;
}
#main_container {
  z-index: 2;
  #gdp3inds{
    position: absolute;
    left: 0;
    top: 0;
    z-index: 3;
  }
  #button01{
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    z-index: 4;
  }
}
#config_container {
  z-index: 9;
  #buttonclose{
    position: absolute;
    right: 1rem;
    top: 1rem;
    z-index: 10;
  }
}
</style>